

  <cfquery name="getAlt" datasource="#client.company_dsn#">
     SELECT PATTERNCODE, NOOFDAYS
     FROM CLKWSALTPATTERN
     WHERE WORKSKEDCODE = '#SkedCode#'
  </cfquery>
  
  <cfset altList ="">
  <cfoutput query="getAlt">
      <cfloop from="1" to="#NOOFDAYS#" index="i">
          <cfset altList = ListAppend(altList,"#PATTERNCODE#")>
      </cfloop>
  </cfoutput>
  
  <cfscript>
      ddate = DateAdd( "d",1,sFrom);
      diff = DateDiff("d",effDate,ddate);
      while ( diff gt 7 )
          diff = diff - 7;
      
      if ( not diff )
          diff = 1;
      sPattern = 	ListGetAt( altList, diff );
  </cfscript>
  
  <cfquery name="getlkDTL" datasource="#client.company_dsn#">
      SELECT DESCRIPTION, DAYTYPE, TIMEIN, TIMEOUT, CATEGORY
      FROM CLKWSPATTERN 
      WHERE PATTERNCODE = '#sPattern#'
  </cfquery>  
